$(function(){

    var total = null;
    var index = 1;
    var page = 1;

    //  渲染商品列表
    function render(){
        $.ajax({
            url: "http://127.0.0.1:9090/api/getmoneyctrl",
            data: { pageid: page },
            dataType: "json",
            success: function (result) {
                console.log(result);
                $(".mm-product").html(template("temp-list", result));
                total = Math.ceil(result.totalCount / result.pagesize);
            }
        });
    }
    render();

    // 上一页
    $(".prev").on("click", function () {
        if (index <= 1) {
            return;
        }
        index--;
        page = index;
        render();
    });
    // 下一页
    $(".next").on("click", function () {
        if (index >= total - 1) {
            return;
        }
        index++;
        page = index;
        render();
        console.log(index);
    });


    $(".mm-product").on("click",".item", function(){
        var id = $(this).data("id");
        location.href = ""
    });

});